home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / msd / MSDaRT50Eval.msi / Binary.ExternalScript.vbs < prev    next >
Encoding:
Text File  |  2007-12-07  |  4.6 KB  |  140 lines

  1. Const WindowsFolder = 0
  2. Const OKOnly = 0 
  3. Const Critical = 16 
  4. Const Exclamation = 48
  5. Const PROGRAM_FILES = &H26&
  6.  
  7.  
  8. ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  9. '   Function: LogInfo
  10. '   Params: msg - Value to be sent to debug stream
  11. '   Description:  Logs information to debug stream
  12. '   Returns: Nothing
  13. '''''''''''''''''''''''''''''''''''''''''''''''''''''''
  14. Function LogInfo(msg) 
  15.     Dim rec
  16.     Set rec = Session.Installer.CreateRecord(1) 
  17.     rec.StringData(0) = "LogInfo:" & msg
  18.     LogInfo = Session.Message(&H04000000, rec)
  19. End Function
  20.  
  21. Function SetProgramFiles
  22.     On Error Resume Next
  23.     LogInfo("Setting default directory to 'Program Files'")
  24.     Set objShell = CreateObject("Wscript.Shell")
  25.     if objShell is Nothing then
  26.         LogInfo("Unable to create wscript.shell")
  27.     end if
  28.     Set shellApp = CreateObject("Shell.Application")
  29.     if shellApp is Nothing then
  30.         LogInfo("Unable to create Shell.Application")
  31.     end if
  32.     Set objFolder = shellApp.Namespace(PROGRAM_FILES)
  33.     if objFolder is Nothing then
  34.         LogInfo("Unable to get objShell.Namespace(PROGRAM_FILES)")
  35.     end if
  36.     Set objFolderItem = objFolder.Self
  37.     if objFolderItem is Nothing then
  38.         LogInfo("Unable to get Set objFolderItem = objFolder.Self")
  39.     end if
  40.     objShell.CurrentDirectory = objFolderItem.Path
  41.     LogInfo("Setting Default Working Directory to " & objFolderItem.Path)
  42.     set objShell = Nothing
  43.     set shellApp = Nothing
  44.     set objFolder = Nothing
  45.     set objFolderItem = Nothing
  46. End Function
  47.  
  48.  
  49. ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  50. '   Function: CheckNextTarget
  51. '   Params: N/A
  52. '   Description:  Checks path validity
  53. '   Returns: Success or Failure
  54. '''''''''''''''''''''''''''''''''''''''''''''''''''''''
  55. Function CheckNextTarget
  56.     On Error Resume Next
  57.  
  58.     SetProgramFiles
  59.     path = Session.Property("TARGETDIR")
  60.  
  61.     Set fs=CreateObject("Scripting.FileSystemObject")
  62.         LogInfo "CheckNextTargetPath {" & path & "}"
  63.     If fs.FolderExists(path) Then
  64.         Session.Property("NextValidTarget") = "True"
  65.         CheckNextTarget = True
  66.         LogInfo "CheckNextTarget Function Result {" & CheckNextTarget & "}"
  67.         set fs = Nothing
  68.         Exit Function
  69.     End If
  70.     fs.CreateFolder(path)
  71.     CheckNextTarget = fs.FolderExists(path)
  72.     Session.Property("NextValidTarget")=CStr(CheckNextTarget)
  73.     If CheckNextTarget Then
  74.         Session.Property("TARGETDIR")=fs.GetFolder(path).Path
  75.         fs.DeleteFolder(path)
  76.     End If
  77.     set fs=Nothing
  78.     LogInfo " CheckNextTarget Function Result {" & CheckNextTarget & "}"
  79. End Function
  80.  
  81.  
  82. ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  83. '   Function: VerifyBrowseTarget
  84. '   Params: N/A
  85. '   Description:  Called by browse button for a valid starting point
  86. '   Returns: Success or Failure
  87. '''''''''''''''''''''''''''''''''''''''''''''''''''''''
  88. Function VerifyBrowseTarget
  89.  
  90.     LogInfo "Running VerifyBrowseTarget"
  91.  
  92.     If CheckNextTarget Then
  93.         LogInfo "Should be set to:" & Session.Property("TARGETDIR")
  94.         Exit Function
  95.     End If
  96.     Session.Property("NextValidTarget") = "True"
  97.     Set fs=CreateObject("Scripting.FileSystemObject")
  98.     Session.Property("TARGETDIR")= CreateObject("WScript.Shell").ExpandEnvironmentStrings("%PROGRAMFILES%")& "\" & Session.Property("Name")
  99.     LogInfo "Invalid path entered, resetting to " & Session.Property("TARGETDIR")
  100.     Set fs= Nothing
  101. End Function
  102.  
  103. ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  104. '   Function: VerifyNextTarget
  105. '   Params: N/A
  106. '   Description:  Called by next button for a valid install point
  107. '   Returns: Success or Failure
  108. '''''''''''''''''''''''''''''''''''''''''''''''''''''''
  109. Function VerifyNextTarget
  110.  
  111.     LogInfo "Running VerifyNextTarget"
  112.  
  113.     If CheckNextTarget Then
  114.         Exit Function
  115.     End If
  116.     MsgBox Session.Property("InvalidTarget"), Critical Or OKOnly, Session.Property("Name")
  117. End Function
  118.  
  119. ''''''''''''''''''''''''''''''''''''''''''''''''''''''
  120. '   Function: VerifyNextCustomInstall
  121. '   Params: N/A
  122. '   Description:  Called by next button for a valid custom installation
  123. '   Returns: Nothing
  124. '''''''''''''''''''''''''''''''''''''''''''''''''''''''
  125. Function VerifyNextCustomInstall
  126.  
  127.     LogInfo "Running VerifyNextCustomInstall"
  128.  
  129.     Session.Property("NextValidCustomInstall") = "True"
  130.     
  131.     if Session.Property("Installed") <> "" Then Exit Function
  132.  
  133.     If Session.FeatureRequestState("CrashAnalyzer") <> 3 And Session.FeatureRequestState("ERDCommander") <> 3 And _
  134.        Session.FeatureRequestState("FileRestore") <> 3 Then
  135.         Session.Property("NextValidCustomInstall") = "False"
  136.         MsgBox Session.Property("InvalidCustomInstall"), Critical Or OKOnly, Session.Property("Name")
  137.         Exit Function
  138.     End If
  139.  
  140. End Function